

// 数据回显ajax

$.ajax({
    type: "post",
    url: "/js/showhometeaPage",
    data: null,
    dataType: "json",
    success: function (data) {
        let teashowdiv = document.querySelector(".siximgs");
        teashowdiv.innerHTML = data;
    }
})




/*
    鼠标滑动事件js
*/

//用js检测鼠标滚轮距离顶部位置来给div添加动画
window.onscroll = function () {
    let siximgs = document.querySelector(".siximgs");
    //检测鼠标滚轮距离顶部位置
    let top = document.documentElement.scrollTop;
    console.log(top);
    //要设置到DIV显示出来时给div添加动画 也可以设置一个数值只要保证div出来给它加动画即可
    if (top > 340) {
        siximgs.style.animation = "centerkey 1s linear forwards" //添加动画
    }
}




// 点击跳转显示茶页面
function showTeaPage(teaid) {
    // 发送ajax请求获取本地存储
    $.ajax({
        type: "post",
        url: "/js/showTeaPageGetLocal",
        data: null,
        dataType: "json",
        success: function (data) {
            let getteaobj = [];
            let teaarr = JSON.parse(data);
            for (let i = 0; i < teaarr.length; i++) {
                if (teaarr[i].teaid == teaid) {
                    getteaobj.push(teaarr[i]);
                    break;
                }
            }
            localStorage.showTea = JSON.stringify(getteaobj);
            window.location.href = './showteapage.html';
        }
    })
}




